//
//  ViewController.m
//  26-Masonry
//
//  Created by GivenBmli on 16/8/18.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//   1.使用Masonry ,不用给初始frame
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor colorWithRed:1.000 green:0.689 blue:0.692 alpha:1.000];
//    添加约束前,需要把视图添加到父视图上
    [self.view addSubview:view];
//    设置该视图约束
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        
    }];
//    2.添加蓝色视图,宽高个100 居中
    UIView *blueview =[UIView new];
    blueview.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blueview];
    [blueview mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.mas_equalTo (self.view.mas_width).multipliedBy(0.5f);
        make.height.mas_equalTo(100);
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
    }];
//    添加黄色,宽高与蓝色相同,与蓝色相距10
    UIView *yellowiew =[UIView new];
    yellowiew.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:yellowiew];
    [yellowiew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.centerX.height.mas_equalTo(blueview);
        make.top.mas_equalTo(blueview.mas_bottom).mas_offset(10);
//        make.centerX.mas_equalTo(blueview.mas_bottom);
    }];
//    yellowiew.left = self.view.left*1.0f + 0;
//    [NSLayoutConstraint constraintWithItem:yellowiew attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
//    
//      [NSLayoutConstraint constraintWithItem:yellowiew attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1 constant:0];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
